package xpn.business.fund_return.entity.attribution;

import org.springframework.context.ApplicationContextException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class AttributionService {
    @Resource
    private AttributionDao attributionDao;

//    @Resource
//    private FrCaseService frCaseService;

    public Attribution save(Attribution attribution) {
        if (Objects.isNull(attribution.getId())) {
            Attribution exist = attributionDao.findAllByCaseId(attribution.getCaseId());
            if (Objects.nonNull(exist)) {
                throw new ApplicationContextException("该表单已存在，请勿重复创建");
            }
        }
//        frCaseService.changeWriteStatus(attribution.getCaseId(), CaseWriteStatus.Belong);
        //提出公共字段保存至FrCase
        return attributionDao.save(attribution);
    }
}
